package order;

import chart.Figure;
import chart.HistogramChart;
import chart.LineCHart;
import chart.PieChart;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: fzykd
 * Date: 2023-03-21
 * Time: 14:44
 */

public class SimpleFactory {

    public Figure createFigure(String type){
        Figure figure = null;

        System.out.println("简单工厂模式");

        if (type.equals("饼状图")){
            figure = new PieChart();
            figure.setName("饼状图");
        }else if (type.equals("柱状图")){
            figure = new HistogramChart();
            figure.setName("柱状图");
        }else if (type.equals("折线图")){
            figure = new LineCHart();
            figure.setName("折线图");
        }else {
            System.out.println("没有你要的图形");
        }

        return figure;

    }
}
